	function clsMyCardViewInout(){
		this.idx = null;
		this._HTMLDom = null;
		this._init();	
	}
	
	clsMyCardViewInout.prototype = {
		_init: function(){
			var $layer = $("section#my_card_view>section>div.my_card_tab a")
			this._HTMLDom = {
				"$layer": $layer	
				, "$view": $("section#my_card_view>section>div.my_card_record")
			}	
		}
		, setIdx: function(n){
			if(this.idx==n) return;
			this.idx = n;
			this._HTMLDom["$view"].hide().eq(n).show();
			this._HTMLDom["$layer"].removeClass("ui-btn-active").eq(n).addClass("ui-btn-active");
		}
		, $getTab: function(){			
			return this._HTMLDom["$layer"];
		}
	}

	//스코어카드-OUT
	function clsMyCardViewOut(){
		this.listData = null;		
		this._HTMLDom = null;
		this._init();
	}
	
	clsMyCardViewOut.prototype = {
		_init: function(){
			var $layer = $("section#my_card_view>section>div.my_card_record");			
			this._HTMLDom = {
				"$layer": $layer	
				, "$element": $layer.find("tbody tr:first")
				, "$select": $layer.find("tbody tr:first>td:eq(2)")				
			}
			$layer.find("tfoot tr td:eq(1)").html("OUT소계");
			$layer.find("tbody").empty();
		}
		, setList: function(thisData){
			this.listData = thisData;
			this.display()
		}
		, display:function(){
			var $layer = this._HTMLDom["$layer"];
			var $element = this._HTMLDom["$element"];
			var thisClass = this;
			
			$layer.find("tbody").empty();
			
			for(var i=0;i<9;++i){
				$layer.find("tbody").append($element.clone(true));
			}
			
			$layer.find("tbody tr").each(function(n){				
				$(this).find("td:eq(0)").html(n+1);				
				$(this).find("td:eq(1)").html(thisClass.listData["파"][n]);
				$(this).find("td:eq(2)").html(thisClass.listData["증감"][n]);
				$(this).find("td:eq(3)").html(thisClass.listData["스코어"][n]);	
			});
			
			//소계
			$layer.find("tfoot tr:eq(0) td:eq(1)").html(this.listData["코스파"]);
			$layer.find("tfoot tr:eq(0) td:eq(2)").html(this.listData["코스증감"]);
			$layer.find("tfoot tr:eq(0) td:eq(3)").html(this.listData["코스스코어"]);
			
			//총계
			$layer.find("tfoot tr:eq(1) td:eq(1)").html(this.listData["전체파"]);
			$layer.find("tfoot tr:eq(1) td:eq(2)").html(this.listData["전체증감"]);
			$layer.find("tfoot tr:eq(1) td:eq(3)").html(this.listData["전체스코어"]);
			
		}	
		, getSum: function(){
			return ;	
		}
	}
	
	//스코어카드-IN
	function clsMyCardViewIn(objControl){
		this.objControl = objControl;
		this.listData = null;		
		this._HTMLDom = null;
		this._init();
	}
	
	clsMyCardViewIn.prototype = {
		_init: function(){
			var $layer = $("section#my_card_view>section>div.my_card_record:eq(1)");			
			this._HTMLDom = {
				"$layer": $layer	
				, "$element": $layer.find("tbody tr:first")
				, "$select": $layer.find("tbody tr:first>td:eq(2)")				
			}
			
			$layer.find("tfoot tr td:eq(0)").html("IN소계");			
			$layer.find("tbody").empty();
		}
		, setList: clsMyCardViewOut.prototype.setList
		, display: clsMyCardViewOut.prototype.display
	}
	
	//데이터연동		
	function clsComm_MyCardView(){
		this.scoreList = null;
		this.scoreListRequest = null;
		
		this._init();
	}
		
	clsComm_MyCardView.prototype = {
		_init: function(){
			this.scoreListRequest = {
				"스코어코드": null
			}	
		}
//------------------------ 스코어카드목록------------------------//		
		, getScoreList: function(){
			var thisClass = this;
						
			var szReserv_seq = this.scoreListRequest["예약코드"];		
			
			var objJson = new MJson();
        	var cm = new ConnectionManager();

			objJson.putClient("userid", "golfin3");
        	objJson.putPub("sid", "US001");
        	objJson.putPub("servicename", "getMyScoreCard");
        		
        	objJson.putParameter("reservSeq", szReserv_seq);
        
        	cm.requestGet(objJson.getJsonString(), function(ret){
				
				var items = ret["msp"]["contents"]["items"];
				if(items){
					
					thisClass.scoreList = [];
					
					if(!items.length) items = new Array(items);
					
					
					
					var _parTSum = 0;
					var _calTSum = 0;
					var _scoreTSum = 0;
						
					for(var i=0;i<items.length;i++){
						var obj = items[i];
						
						var _parSum = 0;
						var _calSum = 0;
						var _scoreSum = 0;						
						
						thisClass.scoreList.push({
							"홀": 0
							, "파": []
							, "증감": []
							, "스코어": []							
							, "코스파": 0
							, "코스증감": 0
							, "코스스코어": 0
							, "전체파": 0
							, "전체증감": 0
							, "전체스코어": 0
						});
						
						//홀별
						for(j=0;j<_util.nvl(obj["holeCnt" + (i+1)], 0);j++){
							
							var _par = _util.nvl(obj["par" + (j+1) + "h"], 0);							
							var _score = _util.nvl(obj["score" + (j+1) + "h"], 0);		
							var _cal = _score-_par;					
						
							thisClass.scoreList[i]["파"].push(_par);
							thisClass.scoreList[i]["증감"].push(_cal);
							thisClass.scoreList[i]["스코어"].push(_score);
							
							_parSum += thisClass.scoreList[i]["파"][j];
							_calSum += thisClass.scoreList[i]["증감"][j];
							_scoreSum += thisClass.scoreList[i]["스코어"][j];
						}
						
						//코스별소계
						thisClass.scoreList[i]["코스파"] = _parSum;
						thisClass.scoreList[i]["코스증감"] = _calSum;
						thisClass.scoreList[i]["코스스코어"] = _scoreSum;
						
						//전체합계
						_parTSum += _parSum;
						_calTSum += _calSum;
						_scoreTSum += _scoreSum;
					}
					
					for(var i=0;i<thisClass.scoreList.length;++i){
						thisClass.scoreList[i]["전체파"] += _parTSum;
						thisClass.scoreList[i]["전체증감"] += _calTSum;
						thisClass.scoreList[i]["전체스코어"] += _scoreTSum;
					}
				}
				
				$(thisClass).trigger("evtFinishScoreList");
			}, function($err) {
				alert($err);
			});			
		}
		, getScoreListData: function(){
			return this.scoreList;	
		}
		, setScoreListDataRequest: function(key,val){
			return this.scoreListRequest[key]=val;	
		}
//------------------------ 스코어카드목록------------------------//		
	}
	
	//컨트롤파일
	function MyCardView(){			
		this.reserv_seq = null;
		this.inout_idx = 0;
		
		this.objComm = null;
		
		this.objMyCardViewIn = null;
		this.objMyCardViewOut = null;
		this.objMyCardViewInout = null;
	};
	
	MyCardView.prototype = {
	    onPageShow : function() {
	    		    	
	    	$("a").attr("href", "").attr("data-rel", "");	    	
	    	$("section#my_card_view header div.top_title_G div a").attr("data-rel","").attr("data-direction", "");   	   
	    	$("section#my_card_view>section>div.my_card_record").before($("section#my_card_view>section>div.my_card_record").get(0).outerHTML);
	    	this._init();	    	
	    }
	   , _init: function(){	
	   	
	      	this.objComm = new clsComm_MyCardView();
	      	this.objMyCardViewIn = new clsMyCardViewIn();
	      	this.objMyCardViewOut = new clsMyCardViewOut(this);
	      	this.objMyCardViewInout = new clsMyCardViewInout(this);	      	
	      	
	      	this.getParam();
	      	
	      	this._role();
	      	
	      	this._bind();
	      	this._eventFinish();
	    }
	    , _start: function(){
	     	this.spinStart(); 
	     	
	     	this.objComm.setScoreListDataRequest("예약코드", this.reserv_seq);
	      	this.objComm.getScoreList();
	   		this.objMyCardViewInout.setIdx(0);
	   }
		, _eventFinish: function(){
	    	var thisClass = this;
	    	
	    	//스코어정보 조회 완료이벤트			
			$(this.objComm).bind("evtFinishScoreList", function(event){
				var thisData = thisClass.objComm.getScoreListData();
				thisClass.objMyCardViewOut.setList(thisData[0]);
				thisClass.objMyCardViewIn.setList(thisData[1]);				
			});
		}
		, _bind: function(){
			var thisClass = this;
						
			// in/out코스탭 이벤트
			this.objMyCardViewInout.$getTab().click(function(event){
				var idx = thisClass.objMyCardViewInout.$getTab().index($(this));				
				thisClass.objMyCardViewInout.setIdx(idx);
			});
			
			//메뉴
			$("section#my_card_view nav ul li a:eq(0)").click(function(event){
				event.preventDefault();
				$.mobile.changePage( "../inc/navi.html","slide",true);	
			});
			
			//알림
			$("section#my_card_view nav ul li:eq(1)").click(function(event){
				event.preventDefault();
				$.mobile.changePage("../inc/info_booking.html","slide",true);	
			});
			//스코어카드 수정하기
			$("section#my_card_view footer div a:eq(0)").click(function(event){
				event.preventDefault();
				//<--초기화
		 		if(!_gf.MYPAGE_DATA) {
			 		_gf.MYPAGE_DATA  = {
			 			"예약코드": thisClass.reserv_seq	
			 		}
			 	}else {
			 		_gf.MYPAGE_DATA["예약코드"] = thisClass.reserv_seq;
			 	}
			 	//초기화-->
				$.mobile.changePage("my_score_modify.html","slide",true);	
			});
			
			//뒤로가기
			$("section#my_card_view header div.top_title_G div a").click(function(event){
				event.preventDefault();								
				$.mobile.changePage( "my_score_view.html","slide",true);	
			});
		}   
		 , getParam: function(){
	    	if(_gf.MYPAGE_DATA){		 		
			 	this.reserv_seq = _gf.MYPAGE_DATA["예약코드"];		 		
		 	}
	    }
	     , _role: function(){
	    		if(!_util.getLogin("로그인")){
	    			//alert("로그인 후 이용하실 수 있습니다.");		    			
	    			this.goNavi();		
	    			return;
	    		}else {
    				this._start();	    		
    			}
	   }
		, goNavi: function(){			
			$.mobile.changePage("../inc/navi.html","slide",true);
		}
		, spinStart: function(){		
			$.mobile.showPageLoadingMsg();			
		}
		, spinEnd: function(){			
	 		$.mobile.hidePageLoadingMsg();				
		}
		//코스합계
		, changeTSum: function(){
			if(!this.objMyCardViewOut) return;
						
			var outSum = this.objMyCardViewOut.getSummery();
			var inSum = this.objMyCardViewIn.getSummery();
			
			this.objMyCardViewOut.setSummery(inSum);
			this.objMyCardViewIn.setSummery(outSum);
		}
	}
	